<?php

class DefaultController extends AppController {

	public $name = 'default';
	public $kcaptcha_components = array('captcha');		
	function beforeFilter() {
	    parent::beforeFilter(); 
		$this->C_auth->autoRedirect = false; //For override login
	    $this->C_auth->allowedActions = array('login'/* ,'logout','index','menu','main','top' */);

	}
	
	public function login() {	
 		if ($this->C_auth->user()) {
			$userID = $this->C_auth->user('id');			
			$this->redirect($this->C_auth->redirect());
		} else if (!empty($this->data)) {
/* 		    if ( md5(strtolower($this->data['user']['captcha'])) == $this->C_session->read('captcha') ) { */
				$this->set('invalidCaptcha', 0);
			    $safeData = $this->data;
			    $this->C_auth->login($safeData); // autologin
			    $userID = $this->C_auth->user('id');				
			    if ($userID) {				
				    $this->redirect($this->C_auth->redirect());
			    } else {
				    $this->set('msg', '用户名不存在或是密码错误!');
			    }
/* 		    } else {
				$this->set('invalidCaptcha', 1);
            }	 */		
		}	 	
	}
	
	public function logout() {
		$userID = $this->C_auth->user('id');
		$this->redirect($this->C_auth->logout());	
	}
	
	public function index() {
	}
	
	public function menu($id='',$ltype=0) {	
        if(!$ltype){
	        $ltype="0";
        }
        $this->set('id',$id);
        $this->set('ltype',$ltype);			
	}
	public function main() {

	}	
	public function top() {

	}	

	
}